package com.lhnstart.learn.bases.cycle;

/**
 * 升序数组
 *
 * @author lhn
 * @date 2022/11/05 09:55
 * @since 1.0.0
 **/
public class AscendingArray {

    public static void main(String[] args) {
        int initial[] = {10, 12, 45, 90};
        int takeOver[] = new int[5];
        int instNum = 23;
        for (int i = 0; i < takeOver.length; i++) {
            if (initial[i] > instNum) {
                takeOver[i] = instNum;
                for (int j = i; j < initial.length; j++) {
                    takeOver[j + 1] = initial[j];
                }
                break;
            }
            takeOver[i] = initial[i];
        }
        initial = takeOver;

        for (int i = 0; i < initial.length; i++) {
            System.out.println(initial[i]);
        }
    }

}